<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateArticleCategoryTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('article_category', function (Blueprint $table) {
            $table->increments('id');
            $table->enum('type', ['news', 'article','product','page','other'])->default('other')->comment('分类类型');
            $table->integer('parent_id')->default(0)->comment('父ID,0表示一级分类');
            $table->string('name', 100)->default('')->comment('分类名稱');
            $table->string('en_name', 100)->default('')->comment('分类英文名稱');
            $table->tinyInteger('sort')->default(0)->comment('排序');
            $table->timestamps();

            $table->index(['type', 'parent_id'], 'tpi');
            $table->index(['parent_id'], 'pi');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('article_category');
    }
}
